package cn.z;
import java.util.Arrays;
import java.util.Random;
/**
 * @author zchcpywin10
 */
public class RunnableAsynTask implements Runnable {
	/**
	 * 耗时的操作（配置低一些的机器小心CPU 100％，反应慢）
	 */
	private String[] needSomeTime() {
		// int len = 50000
		int len = 5;
		String[] intArray = new String[len];
		Random random = new Random(10);
		// 初始化数组
		for (int i = 0; i < len; i++) {
			intArray[i] = String.valueOf(random.nextInt());
		}
		// 排序
		Arrays.sort(intArray);
		return intArray;
	}
	@Override
	public void run() {
		long startTime = System.currentTimeMillis();
		String[] s = needSomeTime();
		long endTime = System.currentTimeMillis();
		System.out.println("执行任务耗时：" + (endTime - startTime));
		System.out.println("执行任务结果：" + Arrays.toString(s));
	}
}
